package com.module.check;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import base.util.Page;

import com.module.check.manager.PersonalTaskManager;
import com.module.check.vo.PersonalTask;
import com.module.organization.manager.OrganizationManager;
import com.module.organization.vo.Organization;
import com.module.sys.LoginSession;

import flex.messaging.io.ArrayList;

public class PersonalTaskService {

	public Page list(PersonalTask bean, Integer start, Integer limit)
			throws Exception {
		Page page = new Page();
		page.setStart(start);
		page.setLimit(limit);
		OrganizationManager orgm = OrganizationManager.getInstance();
		Organization org = orgm.findById(LoginSession.getOrgid());
		if(bean.getTaskId()==0&&!org.getPid().equals("0"))
			bean.setUserId(LoginSession.getUserid());
		PersonalTaskManager manager = PersonalTaskManager.getInstance();
		page = manager.list(page, bean);
		return page;
	}

	public Map<String,Object> remove(Long id)throws Exception{       
		Map<String,Object> map = new HashMap<String,Object>();
		PersonalTaskManager manager = PersonalTaskManager.getInstance();
		map = manager.delete(id);
		return map;
		
	}	

	public Map<String,Object> save(PersonalTask bean)throws Exception{
		Map<String,Object> map = new HashMap<String,Object>();
		PersonalTaskManager manager = PersonalTaskManager.getInstance();
		map = manager.add(bean);
		return map;

	} 
	
	public PersonalTask findById(Long id)throws Exception{
		PersonalTask bean = new PersonalTask();
		PersonalTaskManager manager = PersonalTaskManager.getInstance();
		bean = manager.findById(id);
		return bean;
	}
	public List<PersonalTask> findByTaskId(Long id)throws Exception{
		PersonalTaskManager manager = PersonalTaskManager.getInstance();
		List<PersonalTask> list = new ArrayList();
		list =manager.findByTaskId(id);
		return list;
	
	}
	
	public Map<String,Object>save(List<PersonalTask> tasklist,Long taskid)throws Exception{
		Map<String,Object> map = new HashMap<String,Object>();
		PersonalTaskManager manager = PersonalTaskManager.getInstance();
		map = manager.add(tasklist,taskid);
		return map;
	}
}
